<template>
	<view>
		<view class="cu-card case no-card">
			<view class="cu-item shadow">
				<u-cell-group v-for="(item, index) in loadList" :key="index">
					<u-cell-item title-width="600" :title="item.researchPlace " @click="goInfo(item.researchId)"
						:label="item.researchName" :value="item.researchDate " :title-width="390"></u-cell-item>

				</u-cell-group>
			</view>
		</view>
	</view>
</template>

<script>
	import proData from "@/common/projectData.js";
	import addTip from "../../components/wxcomponents/struggler-uniapp-add-tip/struggler-uniapp-add-tip.vue"
	import {
		getLoadList
	} from '../../common/api/myupload.js'
	export default {
		data() {
			return {
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					userName: "",
					// researchDate: null,
					// researchName: null,
					// researchAnotherName: null,
					// researchLatinName: null,
					// regionId: null,
					// researchPlace: null
				},
				loadList: [],
				// 设定为无触底加载状态
				canMore: true,
				totalPageSize: 1,
				loadStatus: 'loadmore',
				userInfo:{}
			}
		},
		onLoad() {
			this.getLoadList();
		},
		onReachBottom() {
			uni.showLoading({
				title: "加载中"
			});
			if (!this.canMore) {
				uni.hideLoading()
				return;
			}
			if (this.totalPageSize <= this.queryParams.pageNum) {
				uni.hideLoading()
				return;
			}
			this.loadStatus = 'loading';
			// 模拟数据加载
			this.queryParams.pageNum = this.queryParams.pageNum + 1
		
			this.addRandomData();
			this.loadStatus = 'loadmore';
		},
		methods: {
			addRandomData() {
				this.userInfo = uni.getStorageSync('userInfo');
				this.queryParams.userName=this.userInfo.item.userName;
				getLoadList(this.queryParams).then(res => {
					console.log(res);
					this.loadList = this.loadList.concat(res[1].data.rows);
					this.totalPageSize = Math.ceil(parseInt(res[1].data.total) / this.queryParams.pageSize);
					uni.hideLoading()
				})
			},
			getLoadList() {
				this.userInfo = uni.getStorageSync('userInfo');
				console.log(this.userInfo);
				this.queryParams.userName=this.userInfo.item.userName;
				getLoadList(this.queryParams).then(res => {
					console.log(res);
					this.loadList = res[1].data.rows;
					this.totalPageSize = Math.ceil(parseInt(res[1].data.total) / this.queryParams.pageSize);
				})
			},
			goInfo(id) {
				uni.navigateTo({
					url: '../myupload/myloadinfo?researchId=' + id
				})
			}
		}
	}
</script>

<style>

</style>
